#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>

using namespace std;

class Solution {
public:
    int vis[51][51] = { 0 };
    int dx[4] = { 0,0,1,-1 };
    int dy[4] = { 1,-1,0,0 };
    int n, m;
    int sum = 0;
    int maxAreaOfIsland(vector<vector<int>>& grid) {
        n = grid.size();
        m = grid[0].size();
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (grid[i][j] == 1 && vis[i][j] == 0)
                    sum = max(sum, bfs(grid, i, j));
            }
        }
        return sum;
    }

    int bfs(vector<vector<int>>& grid, int x, int y)
    {
        queue<pair<int, int>> qt;
        qt.push({ x,y });
        vis[x][y] = 1;
        int ret = 1;
        while (qt.size())
        {
            auto [a, b] = qt.front();
            qt.pop();
            for (int i = 0; i < 4; i++)
            {
                int xi = a + dx[i];
                int yi = b + dy[i];
                if (xi >= 0 && xi < n && yi >= 0 && yi < m && grid[xi][yi] == 1 && vis[xi][yi] == 0)
                {
                    qt.push({ xi,yi });
                    ret++;
                    vis[xi][yi] = 1;
                }
            }
        }
        return ret;
    }
};

int main() {
    return 0;
}